package com.vhuomai.system.service.impl;

import com.vhuomai.system.entity.BaseSysLink;
import com.vhuomai.system.mapper.SystemLinkMapper;
import com.vhuomai.system.service.SystemLinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author harris
 */
@Service
public class SystemLinkServiceImpl implements SystemLinkService {
    
    @Autowired
    private SystemLinkMapper linkMapper;
    
    @Override
    public List<BaseSysLink> findAll() {
        return linkMapper.findAll();
    }
    
    @Override
    public List<BaseSysLink> findByIds(List<Integer> ids) {
        return linkMapper.findByIds(ids);
    }
    
    @Override
    public BaseSysLink add(BaseSysLink link) {
        link.setCreateTime(LocalDateTime.now());
        link.setUpdateTime(link.getCreateTime());
        linkMapper.insert(link);
        return link;
    }
    
    @Override
    public void update(BaseSysLink link) {
        link.setUpdateTime(LocalDateTime.now());
        linkMapper.updateSelective(link);
    }
    
    @Override
    public void remove(int id) {
        linkMapper.deleteOne(id);
    }
}
